package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Fm;
import com.hl.sfzy.mapper.FmMapper;
import com.hl.sfzy.service.FmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FmServiceImpl implements FmService {
    @Autowired
    private FmMapper fmMapper;

    @Override
    public int removeByPrimaryKey(Long id) {
        return fmMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return fmMapper.removeBatch(ids);
    }

    @Override
    public int add(Fm fm) {
        return fmMapper.insert(fm);
    }

    @Override
    public Fm findByPrimaryKey(Long id) {
        return fmMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Fm> find(int pageNum, int pageSize) {
        return fmMapper.find(pageNum,pageSize);
    }

    @Override
    public PageInfo<Fm> findByPage(int pageNum, int pageSize, Fm fm) {
        PageHelper.startPage(pageNum,pageSize);
        List<Fm> fms = fmMapper.findByPage(pageNum,pageSize,fm);
        PageInfo<Fm> pageInfo = new PageInfo<>(fms);
        return pageInfo;

    }

    @Override
    public int editByPrimaryKey(Fm fm) {
        return fmMapper.updateByPrimaryKey(fm);
    }
}
